import React, { useState, useEffect } from 'react'
import { request } from 'umi'
export default function Hot() {

    let [list, setList] = useState([])
    const getList = () => {
        request("/api/users").then(res => {
            setList(res)
            console.log(res)
            console.log(list)
        })
    }
    useEffect(() => {
        getList()
    }, [])
    return (
        <div>
            <h1>最热民宿</h1>
            <div style={{
                display: 'flex',
                flexWrap: "wrap",
                justifyContent: "space-around"
            }}>
                {list.length && list.map((ele: any) => (
                    <div key={ele.id} style={{
                        width: "150px",
                        height: "150px",
                        backgroundColor: "#fff",
                        marginTop: "10px",
                        borderRadius: '5px',
                        overflow: "hidden",
                    }}>
                        <img style={{
                            width: "100%"
                        }} src={ele.src} />
                        <p>{ele.addrs}</p>
                        <p>{ele.bz}</p>
                        <p>￥{ele.money}</p>
                    </div>
                ))}
            </div>
        </div>
    )
}
